//路由的拦截处理
import router from "./router/index";
import useUserStore from "./store/user";
import { message } from "ant-design-vue";

//判断是否登录
router.beforeEach((to, from, next) => {
  //除过登录
  if (to.path === "/login") {
    next();
  } else {
    const userStore = useUserStore();
    //判断是否登录了 - token
    if (userStore.token) {
      next();
    } else {
      message.warn("暂无权限");
      //去登陆页面
      next("/login");
    }
  }
});
